//
//  YKCommentCell.m
//  baisi
//
//  Created by 吴高烽 on 2016/10/24.
//  Copyright © 2016年 吴高烽. All rights reserved.
//

#import "YKCommentCell.h"
#import "YKComment.h"
#import "YKUser.h"
//#import <UIImageView+WebCache.h>
#import "UIImageView+YKExtension.h"
@interface YKCommentCell ()
@property (weak, nonatomic) IBOutlet UIImageView *profileImageView;
@property (weak, nonatomic) IBOutlet UIButton *nameButton;
@property (weak, nonatomic) IBOutlet UILabel *likeCountLabel;
@property (weak, nonatomic) IBOutlet UILabel *contentLabel;
@property (weak, nonatomic) IBOutlet UIButton *dingButton;
@property (weak, nonatomic) IBOutlet UILabel *likeCountL;

@end

@implementation YKCommentCell
-(BOOL)canBecomeFirstResponder{
    return YES ;
}
-(BOOL)canPerformAction:(SEL)action withSender:(id)sender{
//    NSLog(@"%@",NSStringFromSelector(action));
    return NO ;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    UIImageView *bgView = [[UIImageView alloc] init];
    bgView.image = [UIImage imageNamed:@"mainCellBackground"];
    self.backgroundView = bgView;
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}
-(void)setComment:(YKComment *)comment{
    _comment = comment;
//    self.profileImageView.layer.cornerRadius = 16 ;
//    self.profileImageView.clipsToBounds = YES ;
//    UIImage *placeholderImage = [[UIImage imageNamed:@"defaultUserIcon"] circleImage];
//    [self.profileImageView sd_setImageWithURL:[NSURL URLWithString:comment.user.profile_image] placeholderImage:placeholderImage];
    
    [self.profileImageView setHeaderImage:comment.user.profile_image];
    [self.nameButton setTitle:comment.user.username forState:UIControlStateNormal];
    if ([comment.user.sex isEqualToString:@"m"]) {
        [self.nameButton setImage:[UIImage imageNamed:@"Profile_manIcon"] forState:UIControlStateNormal];
    }else{
        [self.nameButton setImage:[UIImage imageNamed:@"Profile_womanIcon"] forState:UIControlStateNormal];
    }
    
    self.contentLabel.text = comment.content ;
    NSInteger totalCount =  comment.user.total_cmt_like_count ;
    if (totalCount > 999) {
        self.likeCountLabel.text = [NSString stringWithFormat:@"%1.1fk",totalCount/1000.0];
    }else{
        self.likeCountLabel.text = [NSString stringWithFormat:@"%zd",totalCount];
    }
    self.likeCountLabel.layer.cornerRadius = 4 ;
    self.likeCountLabel.layer.masksToBounds = YES ;
    self.likeCountL.text = [NSString stringWithFormat:@"%zd",comment.like_count];
}
//-(void)setFrame:(CGRect)frame{
////    frame.origin.x = YKTopictCellMargin ;
////    frame.size.width -= 2*YKTopictCellMargin ;
//    [super setFrame:frame];
//}
@end
